package com.ruoyi.common.core.page;

import com.ruoyi.common.constant.Constants;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * description
 *
 * @author tqfeiyang
 * @since 2024/11/28 9:00
 */
@Data
public class PagingQueryDto
{
    @Schema(description = "页码，默认为 1", example = "1")
    private Integer pageNum = Constants.PAGE_DEFAULT_INDEX;

    @Schema(description = "每页显示数量，默认为 10", example = "10")
    private Integer pageSize = Constants.PAGE_DEFAULT_SIZE;

//    @Schema(description = "搜索关键字", example = "")
//    private String keyword = "";

    @Schema(description = "排序字段")
    private String orderBy = "";

    @Schema(description = "排序方式 asc：升序，desc：降序")
    private OrderDirection direction = null;

    public Integer getPageNum()
    {
        if (pageNum == null || pageNum <= 0)
        {
            pageNum = Constants.PAGE_DEFAULT_INDEX;
        }
        return pageNum;
    }

    public Integer getPageSize()
    {
        if (pageSize == null || pageSize <= 0)
        {
            pageSize = Constants.PAGE_DEFAULT_SIZE;
        }
        return pageSize;
    }
}
